@echo off
echo Starting Japan Company CMS System...
echo.

REM Check if Java is installed
java -version >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
    echo Error: Java is not installed or not in PATH
    echo Please install Java 17 or higher
    pause
    exit /b 1
)

REM Check if MySQL is running
echo Checking MySQL connection...
mysql -u root -p123456 -h localhost -e "USE japan_cms;" >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
    echo Warning: Cannot connect to MySQL database
    echo Please make sure MySQL is running and database 'japan_cms' exists
    echo Default credentials: root/123456
    echo.
)

REM Create uploads directory if not exists
if not exist "uploads" mkdir uploads
if not exist "uploads\images" mkdir uploads\images
if not exist "uploads\files" mkdir uploads\files

echo Starting Spring Boot application...
echo Application will be available at: http://localhost:8080
echo Database monitoring: http://localhost:8080/druid
echo.
echo Press Ctrl+C to stop the application
echo.

REM Run the application
mvn spring-boot:run

pause